<?php
/**
 * Post active record
 *
 * @author Lukas Normantas
 */
class Blog_Model_Post extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->setTableName('blog_posts');
        $this->hasColumn('author_id', 'integer');
        $this->hasColumn('content', 'clob');
        $this->hasColumn('title', 'string', 255);
        $this->hasColumn('category_id', 'string', 255);
        $this->hasColumn('status', 'string', 25, array('default' => 'draft'));
    }

    public function setUp()
    {
        $this->actAs('Timestampable');
        $this->hasOne('Default_Model_User as Author', array(
                'local' => 'author_id',
                'foreign' => 'id',
                'onDelete' => 'CASCADE'
            )
        );
        $this->hasMany('Blog_Model_Comment as Comments', array(
                'local' => 'id',
                'foreign' => 'post_id'
            )
        );
    }
}